/*
 * @Author: xuetao 3168581151@qq.com
 * @Date: 2025-01-06
 * @LastEditors: xuetao 3168581151@qq.com
 * @LastEditTime: 2025-02-08
 * @Description: 
 */
import 'package:flutter/material.dart';
import 'package:chat_client/widgets/global_widgets.dart'; // 引入公共的组件

class ContactsScreen extends StatefulWidget {
  const ContactsScreen({super.key});

  @override
  State<StatefulWidget> createState() => _ContactsScreen();
}

class _ContactsScreen extends State<ContactsScreen> {
  // 数据优化，将 List 中的项统一成一个 Map，简化逻辑
  final List<Map<String, dynamic>> items = [
    {'label': '新朋友', 'icon': Icons.person_add, 'backgroundColor': Colors.amber},
    {'label': '群聊', 'icon': Icons.group, 'backgroundColor': Colors.green},
    {'label': '标签', 'icon': Icons.label, 'backgroundColor': Colors.blue},
  ];

  @override
  Widget build(BuildContext context) {
    return ListView.separated(
      itemCount: items.length, // 总共的项数，包含联系人和特殊项
      itemBuilder: (context, index) {
        return customListInfo(
          title: items[index]['label'],
          icon: items[index]['icon'],
          imageUrl: items[index]['imageUrl'],
          backgroundColor:
              items[index]['backgroundColor'] ?? Colors.amber, // 默认为 amber
        );
      },
      separatorBuilder: (context, index) {
        if (index == 3) {
          return const DividerWithText(text: '我的联系人');
        }
        return buildDivider(); // 默认的分隔线
      },
    );
  }
}
